//
//  YXGradientView.m
//  MockProject
//
//  Created by FanYu on 1/9/2016.
//  Copyright © 2016 niuzhaowang. All rights reserved.
//

#import "YXGradientView.h"

@interface YXGradientView ()

@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) CAGradientLayer *gradientLayer;

@end


@implementation YXGradientView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Setup UI 
- (void)setupUI {
    // self
    self.backgroundColor = [UIColor redColor];
    
    // gradient
    self.gradientLayer = [CAGradientLayer layer];
    self.gradientLayer.colors = @[(id)[UIColor colorWithHexString:@"ff8400"].CGColor,
                            (id)[UIColor colorWithHexString:@"ffc01c"].CGColor];
    self.gradientLayer.startPoint = CGPointMake(0, 0.5);
    self.gradientLayer.endPoint = CGPointMake(1.0, 0.5);
    [self.layer addSublayer:self.gradientLayer];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.gradientLayer.frame = self.bounds;
}

@end
